﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Common;
using System.Data;
using Microsoft.Reporting.WebForms;
using Ewts.Code;

namespace Ewts.RDLC
{
    public partial class MoveOutStorageSltRDLC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //归属地
                ListItem item = new ListItem();
                item.Text = "--请选择--";
                item.Value = "";
              
                DataLib.BLL.City bllLib = new DataLib.BLL.City();
                ddlBelong.DataSource = bllLib.GetList(" flag1='01'");
                ddlBelong.DataTextField = "cityname";
                ddlBelong.DataValueField = "cityname";
                ddlBelong.DataBind();
                ddlBelong.Items.Insert(0, item);



                // 处理地
                ddlGraphic.DataSource = bllLib.GetList(" flag1='02'");
                ddlGraphic.DataTextField = "cityname";
                ddlGraphic.DataValueField = "cityname";
                ddlGraphic.DataBind();
                ddlGraphic.Items.Insert(0, item);
            }

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            this.MoveOutStorageReportView.Visible = true;  //设置页面visible：false,点击查询后为true  2013.04.17 梁玲
            string belong = ddlBelong.SelectedValue;
            string graphic = ddlGraphic.SelectedValue;
            string Vload = txtVloadnum.Text;
            string loadnum = txtLoadnum.Text;
            string outStorageNO = txtOutStorageNo.Text;
            string startdate = txtTime1.Text;
            string enddate = txtTime2.Text;
            string customer = txtCum.Text;
            string gCode = txtGoodsCode.Text;
            string gName = txtGoodsName.Text;
            string position = txtPosition.Text;
            string barcode = txtBarCode.Text;
            string ConsumMan = txtConsumMan.Text;
            string boxid = txtBOXID.Text;
            

            if ((!PageValidate.IsDateTime(startdate) && PageValidate.IsDateTime(enddate)) || ((PageValidate.IsDateTime(startdate) && !PageValidate.IsDateTime(enddate))))
            {
                MessageBox.Show(this, "日期格式不合法，时间段填写完整！");
                return;
            }

            DataLib.BLL.OutStorage bll = new DataLib.BLL.OutStorage();

            DataTable dt = bll.getDtByUnionWhere(belong, loadnum, outStorageNO, graphic,
                gCode,startdate,enddate,barcode,ConsumMan,boxid,customer,"5",gName,"");

            ReportDataSource rds = new ReportDataSource("MoveOutStorageSltDS", dt);
            MoveOutStorageReportView.LocalReport.DataSources.Clear();
            MoveOutStorageReportView.LocalReport.DataSources.Add(rds);
            new RDLCPrinter().FillRow(dt, 3, 30, 30);
            MoveOutStorageReportView.LocalReport.Refresh();

        }
    }
}